import { _decorator, assert, AudioClip, AudioSource, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('AudioManager')
export class AudioManager extends Component {
    private static _instance: AudioManager = null;
    @property(AudioClip)
    public bgmClip: AudioClip = null;

    @property(AudioClip)
    public sunPoint: AudioClip = null;

    @property(AudioSource)
    public _audioSource: AudioSource = null;


    /**
 * 获取实例
 */
    public static get Instance(): AudioManager {
        return this._instance;
    }

    protected onLoad(): void {
        const audioSource = this.node.getComponent(AudioSource);

        this._audioSource = audioSource;
    }

    playBgm() {
        // 播放音乐
        this._audioSource.clip = this.bgmClip;
        this._audioSource.play();
    }

    playOneShot(type) {
        this._audioSource.playOneShot(this[type], 0.5);
    }

    start() {

    }

    update(deltaTime: number) {

    }
}


